﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Chenxin.Lib.Hr.BLL
{
    public class Struct_UserDepartRelation
    {
        public Struct_UserDepartRelation()
        { }

        #region  成员方法
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetUserByDepartId(System.Collections.Hashtable hsParams)
        {
            string strWhere = "";
            //order文
            string strOrder = "Struct_UserDepartRelation.IsBelong desc";
            //当前页数
            int intCurPage = 1;
            //显示行数
            int intRowCnt = 10;
            //查询表格
            string tablename = "Struct_UserDepartRelation";
            //select文
            string TableFieldList = "userId,UserCode,UserName,CASE WHEN IsBelong='1' THEN '√' ELSE '' END  AS IsBelong,CASE WHEN IsRoleA='1' THEN '√' ELSE '' END  AS IsRoleA,CASE WHEN IsRoleB='1' THEN '√' ELSE '' END  AS IsRoleB,CASE WHEN IsRoleC='1' THEN '√' ELSE '' END  AS IsRoleC,CASE WHEN IsRoleD='1' THEN '√' ELSE '' END  AS IsRoleD,CASE WHEN IsRoleE='1' THEN '√' ELSE '' END  AS IsRoleE,CASE WHEN ViewPubHouse='1' THEN '√' ELSE '' END  AS ViewPubHouse,CASE WHEN ViewPrivHouse='1' THEN '√' ELSE '' END  AS ViewPrivHouse,CASE WHEN ViewHideHouse='1' THEN '√' ELSE '' END  AS ViewHideHouse,CASE WHEN ViewPubDemand='1' THEN '√' ELSE '' END  AS ViewPubDemand,CASE WHEN ViewPrivDemand='1' THEN '√' ELSE '' END  AS ViewPrivDemand,CASE WHEN ViewRealCustomer='1' THEN '√' ELSE '' END  AS ViewRealCustomer,CASE WHEN ViewFakeCustomer='1' THEN '√' ELSE '' END  AS ViewFakeCustomer,CASE WHEN EditPrimaryHouse='1' THEN '√' ELSE '' END  AS EditPrimaryHouse,"
                + "CASE WHEN EditNormalHouse='1' THEN '√' ELSE '' END  AS EditNormalHouse,CASE WHEN DelTrace='1' THEN '√' ELSE '' END  AS DelTrace,CASE WHEN CanProtect='1' THEN '√' ELSE '' END  AS CanProtect,CASE WHEN CanLockHouse='1' THEN '√' ELSE '' END  AS CanLockHouse,CASE WHEN ViewLockHouse='1' THEN '√' ELSE '' END  AS ViewLockHouse,CASE WHEN ViewChange='1' THEN '√' ELSE '' END  AS ViewChange,CASE WHEN CanChangeConfirm='1' THEN '√' ELSE '' END  AS CanChangeConfirm,CASE WHEN ViewEntrust='1' THEN '√' ELSE '' END  AS ViewEntrust,CASE WHEN CanCancelTrust='1' THEN '√' ELSE '' END  AS CanCancelTrust,CASE WHEN UnCancelTrust='1' THEN '√' ELSE '' END  AS UnCancelTrust,CASE WHEN CanDelTrust='1' THEN '√' ELSE '' END  AS CanDelTrust,CASE WHEN ViewHrInfo='1' THEN '√' ELSE '' END  AS ViewHrInfo,CASE WHEN ViewHrChange='1' THEN '√' ELSE '' END  AS ViewHrChange,CASE WHEN ViewAttendance='1' THEN '√' ELSE '' END  AS ViewAttendance,"
                + "CASE WHEN ViewWatching='1' THEN '√' ELSE '' END  AS ViewWatching,CASE WHEN EditWatching='1' THEN '√' ELSE '' END  AS EditWatching,CASE WHEN EditKey='1' THEN '√' ELSE '' END  AS EditKey,CASE WHEN UseKey='1' THEN '√' ELSE '' END  AS UseKey,CASE WHEN EditKeyUsing='1' THEN '√' ELSE '' END  AS EditKeyUsing,CASE WHEN EditKeyUsing='1' THEN '√' ELSE '' END  AS EditKeyUsing,CASE WHEN EditTrust='1' THEN '√' ELSE '' END  AS EditTrust,CASE WHEN CancelLockHouse='1' THEN '√' ELSE '' END  AS CancelLockHouse,CASE WHEN ViewPubCustomer='1' THEN '√' ELSE '' END  AS ViewPubCustomer,CASE WHEN ViewPrivCustomer='1' THEN '√' ELSE '' END  AS ViewPrivCustomer,CASE WHEN EditPubDemand='1' THEN '√' ELSE '' END  AS EditPubDemand,CASE WHEN EditPrivDemand='1' THEN '√' ELSE '' END  AS EditPrivDemand,CASE WHEN ViewTelLog='1' THEN '√' ELSE '' END  AS ViewTelLog,CASE WHEN ViewBusiness='1' THEN '√' ELSE '' END  AS ViewBusiness,"
                + "CASE WHEN ViewVacation='1' THEN '√' ELSE '' END  AS ViewVacation,CASE WHEN ViewAnnualLeave='1' THEN '√' ELSE '' END  AS ViewAnnualLeave,CASE WHEN ViewUserLog='1' THEN '√' ELSE '' END  AS ViewUserLog,CASE WHEN DelHouse='1' THEN '√' ELSE '' END  AS DelHouse,CASE WHEN EditPubCustomer='1' THEN '√' ELSE '' END  AS EditPubCustomer,CASE WHEN EditPrivCustomer='1' THEN '√' ELSE '' END  AS EditPrivCustomer,CASE WHEN ViewStock='1' THEN '√' ELSE '' END  AS ViewStock,CASE WHEN IsControl='1' THEN '√' ELSE '' END  AS IsControl,CASE WHEN viewtrace='1' THEN '√' ELSE '' END  AS viewtrace,CASE WHEN CanDeletePicture='1' THEN '√' ELSE '' END  AS CanDeletePicture,CASE WHEN CanUploadPicture='1' THEN '√' ELSE '' END  AS CanUploadPicture,CASE WHEN CanPublishHouse='1' THEN '√' ELSE '' END  AS CanPublishHouse";
            string FieldList = "userId,UserCode,UserName,IsBelong,IsRoleA,IsRoleB,IsRoleC,IsRoleD,IsRoleE,ViewPubHouse,ViewPrivHouse,ViewHideHouse,ViewPubDemand,ViewPrivDemand,ViewRealCustomer,ViewFakeCustomer,EditPrimaryHouse,EditNormalHouse,DelTrace,CanProtect,CanLockHouse,ViewLockHouse,ViewChange,CanChangeConfirm,ViewEntrust,CanCancelTrust,UnCancelTrust,CanDelTrust,ViewWatching,EditWatching,EditKey,UseKey,EditKeyUsing,EditTrust,CancelLockHouse,ViewPubCustomer,ViewPrivCustomer,EditPubDemand,EditPrivDemand,ViewTelLog,ViewBusiness,ViewHrInfo,ViewHrChange,ViewAttendance,ViewVacation,ViewAnnualLeave,ViewUserLog,DelHouse,EditPubCustomer,EditPrivCustomer,ViewStock,IsControl,viewtrace,CanDeletePicture,CanUploadPicture,CanPublishHouse";

            //排序项目
            if (hsParams.ContainsKey("strwhere"))
            {
                strWhere = hsParams["strwhere"].ToString();
            }
            else
            {
                strWhere = "DepartId='" + Guid.Empty.ToString() + "'";
            }

            //当前页数
            if (hsParams.ContainsKey("page"))
            {
                intCurPage = Convert.ToInt32(hsParams["page"]);
            }
            //显示行数
            if (hsParams.ContainsKey("rows"))
            {
                intRowCnt = Convert.ToInt32(hsParams["rows"]);
            }

            DataSet ds = Chenxin.Lib.Hr.DAL.Struct_UserDepartRelation.GetList(intCurPage, intRowCnt,strOrder,tablename,strWhere,FieldList,TableFieldList,true);

            return ds;
        }

        #endregion 成员方法
    }
}
